home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / text / faqs / motif-faq.part5 < prev    next >
Encoding:
Internet Message Format  |  1994-04-16  |  70.9 KB

  1. Subject: Motif FAQ (Part 5 of 5)
  2. Newsgroups: comp.windows.x.motif,news.answers,comp.answers
  3. From: dealy@kong.gsfc.nasa.gov (Brian Dealy)
  4. Date: 14 Apr 1994 15:20:38 -0400
  5.  
  6. Archive-name: motif-faq/part5
  7. Last-modified: APR 04, 1994
  8. Version: 3.6
  9.  
  10.  
  11.  
  12.  
  13.  
  14. -----------------------------------------------------------------------------
  15. Subject: 126)  TOPIC: ICONS
  16.  
  17. Iconification/de-iconification is a co-operative process between a client and
  18. a window manager.  The relevant standards are set by ICCCM.  Mwm is ICCCM
  19. compliant.  The toplevel (non-override-redirect) windows of an application may
  20. be in three states: WithdrawnState (neither the window nor icon visible),
  21. NormalState (the window visible) or IconicState (the icon window or pixmap
  22. visible).  This information is contained in the WM_STATE property but ordinary
  23. clients are not supposed to look at that (its values have not yet been
  24. standardised).  Movement between the three states is standardised by ICCCM.
  25.  
  26. -----------------------------------------------------------------------------
  27. Subject: 127)  How can I keep track of changes to iconic/normal window state?
  28.  
  29. Answer: You can look at the WM_STATE property, but this breaks ICCCM
  30. guidelines.  ICCCM compliant window managers will map windows in changing them
  31. to normal state and unmap them in changing them to iconic state. Look for
  32. StructureNotify events and check the event type:
  33.  
  34.         XtAddEventHandler (toplevel_widget,
  35.                         StructureNotifyMask,
  36.                         False,
  37.                         StateWatcher,
  38.                         (Opaque) NULL);
  39.         ....
  40.         void StateWatcher (w, unused, event)
  41.         Widget w;
  42.         caddr_t unused;
  43.         XEvent *event;
  44.         {
  45.                 if (event->type == MapNotify)
  46.                         printf ("normal\n");
  47.                 else if (event->type == UnmapNotify)
  48.                         printf ("iconified\n");
  49.                 else    printf ("other event\n");
  50.         }
  51.  
  52.  
  53. If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
  54. it:
  55.  
  56.         /*
  57.         ------------------------------------------------------------------
  58.         Try a function such as CheckWinMgrState below which returns one of
  59.         IconicState | NormalState | WithdrawnState | NULL :
  60.         ------------------------------------------------------------------
  61.         */
  62.         #define WM_STATE_ELEMENTS 1
  63.  
  64.         unsigned long *CheckWinMgrState (dpy, window)
  65.         Display *dpy;
  66.         Window window;
  67.         {
  68.           unsigned long *property = NULL;
  69.           unsigned long nitems;
  70.           unsigned long leftover;
  71.           Atom xa_WM_STATE, actual_type;
  72.           int actual_format;
  73.           int status;
  74.  
  75.             xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
  76.  
  77.             status = XGetWindowProperty (dpy, window,
  78.                           xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
  79.                           False, xa_WM_STATE, &actual_type, &actual_format,
  80.                           &nitems, &leftover, (unsigned char **)&property);
  81.  
  82.             if ( ! ((status == Success) &&
  83.                         (actual_type == xa_WM_STATE) &&
  84.                         (nitems == WM_STATE_ELEMENTS)))
  85.                 {
  86.                 if (property)
  87.                     {
  88.                     XFree ((char *)property);
  89.                     property = NULL;
  90.                     }
  91.                 }
  92.             return (property);
  93.         } /* end CheckWinMgrState */
  94.  
  95.  
  96. -----------------------------------------------------------------------------
  97. Subject: 128)  How can I check if my application has come up iconic?  I want
  98. to delay initialisation code and other processing.
  99.  
  100. Answer: Use XtGetValues and check for the XmNinitialState value of the
  101. toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
  102. is not iconic.
  103.  
  104.  
  105.  
  106.  
  107. -----------------------------------------------------------------------------
  108. Subject: 129)  How can I start my application in iconic state?
  109.  
  110. Answer: From the command line
  111.  
  112.         application -iconic
  113.  
  114. Using the resource mechanism, set the resource XmNinitialState to IconicState
  115. of the toplevel shell widget (the one returned from XtInitialise).
  116.  
  117. -----------------------------------------------------------------------------
  118. Subject: 130)  How can an application iconify itself?
  119.  
  120. Answer: In R4 and later, use the call XIconifyWindow.
  121.  
  122. For R3, send an event to the root window with a type of WM_CHANGE_STATE and
  123. data IconicState.
  124.  
  125.         void
  126.         IconifyMe (dpy, win)
  127.         Display *dpy;
  128.         Window win;     /* toplevel window to iconify */
  129.         {
  130.                 Atom xa_WM_CHANGE_STATE;
  131.                 XClientMessageEvent ev;
  132.  
  133.                 xa_WM_CHANGE_STATE = XInternAtom (dpy,
  134.                                         "WM_CHANGE_STATE", False);
  135.  
  136.                 ev.type = ClientMessage;
  137.                 ev.display = dpy;
  138.                 ev.message_type = xa_WM_CHANGE_STATE;
  139.                 ev.format = 32;
  140.                 ev.data.l[0] = IconicState;
  141.                 ev.window = win;
  142.  
  143.                 XSendEvent (dpy,
  144.                         RootWindow (dpy, DefaultScreen(dpy)),
  145.                         True,
  146.                         (SubstructureRedirectMask | SubstructureNotifyMask),
  147.                         &ev);
  148.                 XFlush (dpy);
  149.         }
  150.  
  151.  
  152. -----------------------------------------------------------------------------
  153. Subject: 131)  How can an application de-iconify itself?
  154.  
  155. Answer: XMapWindow (XtDisplay (toplevel_widget), XtWindow (toplevel_widget)).
  156.  
  157. -----------------------------------------------------------------------------
  158. Subject: 132)  TOPIC: MISCELLANEOUS
  159.  
  160. -----------------------------------------------------------------------------
  161. Subject: 133)+ How do I controll the repeat rate on a SUN keyboard ??
  162.  
  163.  
  164. Answer:
  165.  
  166.      [...]
  167.  
  168.      -ar1 milliseconds
  169.              This option specifies amount of time in milliseconds
  170.              before   which   a   pressed  key  should  begin  to
  171.              autorepeat.
  172.  
  173.      -ar2 milliseconds
  174.              This option specifies the interval  in  milliseconds
  175.              between autorepeats of pressed keys.
  176.  
  177. Of course this presumes you're using a server based on the MIT sample server.
  178. submitted by: kaleb@x.org (Kaleb Keithley)
  179.  
  180. -----------------------------------------------------------------------------
  181. Subject: 134)  How can I identify the children of a manager widget?
  182.  
  183. Answer: XmNnumChildren (number of widgets in array).
  184.  
  185. -----------------------------------------------------------------------------
  186. Subject: 135)  How do I tell if a scrolled window's scrollbars are visible?
  187.  
  188. Answer: Use XtGetValues() to get the scrollbar widget ID's, then use
  189. XtIsManaged() to see if they are managed (visible).
  190.  
  191. thanks to Ken Lee, klee@synoptics.com
  192.  
  193. -----------------------------------------------------------------------------
  194. Subject: 136)  How can I programatically scroll a XmScrolledWindow in
  195. XmAUTOMATIC mode?
  196.  
  197. Answer: In Motif 1.2, use XmScrollVisible().  If you're using a scrolled text
  198. or scrolled list combination widget, use XmTextScroll() or XmListSet*()
  199. instead.
  200.  
  201. The Motif manuals specifically forbid manipulating the scrollbars directly,
  202. but some people have reported success with XmScrollBarSetValues, with the
  203. "notify" parameter set to "True".
  204.  
  205. thanks to Ken Lee, klee@synoptics.com
  206.  
  207. -----------------------------------------------------------------------------
  208. Subject: 137)  What functions can an application use to change the size or
  209. position of a widget?
  210.  
  211. Answer: Applications should set the values of the XmNx, XmNy, XmNwidth, and
  212. XmNheight resources.
  213.  
  214. Note that many manager widgets ignore the XmNx and XmNy resources of their
  215. children, relying instead on their internal layout algorithms.  If you really
  216. want specific positions, you must use a manager widget that allows them, e.g.,
  217. XmBulletinBoard.
  218.  
  219. Also note that some manager widgets reject size change requests from their
  220. children when certain resources are set (e.g., XmNresizable on XmForm).
  221. Others allow the the children to resize, but clip the results (e.g.,
  222. XmNallowShellResize on shell widgets).  Make sure you have these resources set
  223. to the policy you want.
  224.  
  225. Due to bugs, some widgets (third party widgets) do not respond to changes in
  226. their width and height.  Sometimes, you can get them to respond correctly by
  227. unmanaging them, setting the resources, then managing them again.
  228.  
  229. Under no circumstances should applications use routines like
  230. XtConfigureWidget() or XtResizeWidget().  These routines are reserved for
  231. widget internals and will seriously confuse many widgets.  _ thanks to Ken
  232. Lee, klee@synoptics.com ----------
  233. -------------------------------------------------------------------
  234. Subject: 138)  What widgets should I use to get the look of push buttons, but
  235. the behaviour of toggle buttons?
  236.  
  237. Answer:
  238.   Use the XmToggleButton widget, setting XmNindicatorOn to False and
  239. XmNshadowThickness to 2.
  240.  
  241. thanks to Ken Lee, klee@synoptics.com ----------
  242. -------------------------------------------------------------------
  243. Subject: 139)+ How do I obtain the size of a unmanaged shell widget?
  244.  
  245. Answer: In the code below, use getsize() for widgets which have been managed,
  246. and getsize2() for newly created shell widgets which have not yet been
  247. managed.
  248.  
  249. getsize2() takes two widget parameters because popup dialogs etc.  _consist_
  250. of two separate widgets - the parent shell and the child bulletin board, form,
  251. whatever.  This important distinction (somewhat glossed over in the Motif
  252. manuals) is the cause of a large number of queries in comp.windows.x.motif.
  253. XmCreate...Dialog() functions return the (bulletin board, form, whatever)
  254. _child_ of the pair, not the parent shell.
  255.  
  256. getsize2() takes the _shell_ widget as it's first parameter, and the shell's
  257. _child_ (the bulletin board, form, whatever) as it's second.  Thus, if you are
  258. using code like widget = XmCreate...Dialog() to create your popup dialogs, use
  259. code like getsize2(XtParent(widget),widget,&width,&height) to get the width
  260. and height. If you use e.g. XmCreateDialogShell() or XtCreatePopupShell(),
  261. then you are creating the the shell widget and it's child explicitly, and can
  262. just pass them into getsize2() with no problem.
  263.  
  264. Note: getsize2() calls getsize().
  265.  
  266. /* getsize(widget,width,height);
  267.  * Widget widget;
  268.  * int *width,*height;
  269.  *
  270.  * returns the width and height of a managed widget */
  271.  
  272.  
  273.  
  274.  
  275. void getsize(l,w,h) Widget l; int *w,*h; { Dimension w_,h_,b_;
  276.  
  277. static Arg size_args[] =
  278.   {
  279.   { XmNwidth,0 },
  280.   { XmNheight,0 },
  281.   { XmNborderWidth,0 },
  282.   };
  283.  
  284. size_args[0].value = (XtArgVal)&w_; size_args[1].value = (XtArgVal)&h_;
  285. size_args[2].value = (XtArgVal)&b_;
  286.  
  287. XtGetValues(l,size_args,3);
  288.  
  289. if (w) *w = w_ + b_; if (h) *h = h_ + b_; } /*
  290. getsize2(shell,child,width,height);
  291.  * Widget shell,child;
  292.  * int *width,*height;
  293.  *
  294.  * returns the width, height of an unmanaged shell widget */
  295.  
  296. void getsize2(p,c,w,h) Widget p,c; int *w,*h; { XtSetMappedWhenManaged(p,0);
  297.  
  298. XtManageChild(c);
  299.  
  300. getsize(p,w,h);
  301.  
  302. XtUnmanageChild(c);
  303.  
  304. XtSetMappedWhenManaged(p,-1); } submitted by: [ Huw Rogers  Communications
  305. Software Engineer, NEC Corporation, Tokyo, Japan ] [ Email:
  306. rogersh@ccs.mt.nec.co.jp  Fax: +81-3-5476-1005  Tel: +81-3-5476-1096 ]
  307.  
  308. -----------------------------------------------------------------------------
  309. Subject: 140)  Can I use XtAddTimeOut(), XtAddWorkProc(), and XtAddInput()
  310. with XtAppMainLoop()?
  311.  
  312. Answer: On many systems, the obsolete XtAdd*() functions are not compatible
  313. with the XtAppMainLoop().  Instead, you should use newer XtAppAddTimeOut(),
  314. XtAppAddWorkProc(), and XtAppAddInput() functions with XtAppMainLoop()
  315.  
  316. thanks to Ken Lee, klee@synoptics.com ----------
  317. -------------------------------------------------------------------
  318. Subject: 141)  Why does XtGetValues() XmNx and XmNwidth return extremely large
  319. values.
  320.  
  321. Answer: You must use the 16 bit "Dimension" and "Position" data types for your
  322. arguments.  If you use 32 bit integers, some implementations will fill the
  323. remaining 16 bits with invalid data, causing incorrect return values.  The
  324. *Motif Programmer's Manual* and the widget man pages specify the correct data
  325. type for each resource.
  326.  
  327. thanks to Ken Lee, klee@synoptics.com ----------
  328. -------------------------------------------------------------------
  329. Subject: 142)  Can I specify callback functions in resource files?
  330.  
  331. Answer: To specify callbacks, you must use UIL in addition to or in place of
  332. resource files.  You can, however, specify translations in resource files,
  333. which give you most of the same functionality as callback functions.
  334.  
  335. thanks to Ken Lee, klee@synoptics.com ----------
  336. -------------------------------------------------------------------
  337. Subject: 143)  How do I specify a search path for ".uid" files?  Answer: Use
  338. the UIDPATH environment variable.  It is documented on the MrmOpenHierarchy()
  339. man page.
  340.  
  341. -----------------------------------------------------------------------------
  342. Subject: 144)  XtGetValues() on XmNx and XmNy of my top level shell don't
  343. return the correct root window coordinates.  How do I compute these?
  344.  
  345. Answer: XmNx and XmNy are the coordinates relative to your shell's parent
  346. window, which is usually a window manager's frame window.  To translate to the
  347. root coordinate space, use XtTranslateCoords() or XTranslateCoordinates().
  348.  
  349. thanks to Ken Lee, klee@synoptics.com ----------
  350. -------------------------------------------------------------------
  351. Subject: 145)  Can I use XmGetPixmap() with widgets that have non-default
  352. visual types?
  353.  
  354. Answer: If you're using a different depth, use XmGetPixmapByDepth() instead.
  355.  
  356.  thanks to Ken Lee, klee@synoptics.com ----------
  357. -------------------------------------------------------------------
  358. Subject: 146)  How can I determine the item selected in a option menu or a
  359. RadioBox?
  360.  
  361. Answer: The value of the XmNmenuHistory resource of the XmRowColumn parent is
  362. the widget ID of the last selected item.  It works the same way for all menus
  363. and radio boxes.  thanks to Ken Lee, klee@synoptics.com
  364.  
  365. -----------------------------------------------------------------------------
  366. Subject: 147)  What is the matter with Frame in Motif 1.2?
  367.  
  368. [Last modified: November 92]
  369.  
  370. Answer: This announcement has been made by OSF:
  371.  
  372. "IMPORTANT NOTICE
  373.  
  374. We have discovered two problems in the new 1.2 child alignment resources in
  375. XmFrame. Because some vendors may have committed, or are soon to commit to
  376. field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
  377. limited. We are trying to deal with these in a way that does not cause
  378. hardship for application developers who will develop applications against
  379. various point versions of Motif. OSF's future actions for correction are
  380. summarized.
  381.  
  382. WHAT YOU SHOULD DO AND KNOW
  383.  
  384. 1. Mark the following change in your documentation.
  385.  
  386. On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
  387. under XmNchildVerticalAlignment as follows (what follows is the CORRECT
  388. wording to match the current implementation):
  389.  
  390. XmALIGNMENT_WIDGET_TOP
  391.         Causes the BOTTOM edge of the title area to align
  392.         vertically with the top shadow of the Frame.
  393.  
  394. XmALIGNMENT_WIDGET_BOTTOM
  395.         Causes the TOP edge of the title area to align
  396.         vertically with the top shadow of the Frame.
  397.  
  398. 2. Note the following limitation on resource converters for Motif 1.2 and
  399. 1.2.1 implementations.
  400.  
  401. The rep types for XmFrame's XmNentryVerticalAlignment resource were
  402. incorrected implemented, which means that converters will not work properly.
  403. The following resource settings will not work from a resource file in 1.2 and
  404. 1.2.1:
  405.  
  406.         *childVerticalAlignment: alignment_baseline_bottom
  407.         *childVerticalAlignment: alignment_baseline_top
  408.         *childVerticalAlignment: alignment_widget_bottom
  409.         *childVerticalAlignment: alignment_widget_top
  410.  
  411. If you wish to set these values for these resources (note they are new
  412. constraint resources in XmFrame) you will have to set them directly in C or
  413. via uil.
  414.  
  415. WHAT WE WILL DO
  416.  
  417. The problem described in note #1 above will not be fixed in the OSF/Motif
  418. implementation until the next MAJOR release of Motif.  At that time we will
  419. correct the documentation and modify the code to match those new descriptions,
  420. but we will preserve the existing enumerated values and their behavior for
  421. backward compatibility for that release.
  422.  
  423. The fix for the problem described in note #2 will be shipped by OSF in Motif
  424. 1.2.2.
  425.  
  426. SUMMARY
  427.  
  428. We are sorry for any difficulty this causes Motif users.  If you have any
  429. questions or flames (I suppose I deserve it) please send them directly to me.
  430. We sincerely hope this proactive response is better for our customers than you
  431. having to figure it out yourselves!
  432.  
  433. Libby
  434.  
  435.  
  436. -----------------------------------------------------------------------------
  437. Subject: 148)  What is IMUG and how do I join it?
  438.  
  439. Answer: IMUG is the International Motif User Group founded by Quest Windows
  440. Corporation and co-sponsored by FedUNIX.  IMUG is a non-profit organization
  441. working to keep users informed on technical and standards issues, to
  442. strengthen user groups on a local level, to increase communication among users
  443. internationally, and to promote the use of an international conference as a
  444. forum for sharing and learning more about Motif.  You can join it by
  445.  
  446.  1.  Pay the annual membership fee of $20 USD directly to IMUG.  Contact
  447.  
  448.      IMUG
  449.      5200 Great America Parkway
  450.      Santa Clara,  CA  95054
  451.      (408) 496-1900
  452.      imug@quest.com
  453.  
  454.  2.  Register at the International Motif User Conference, and automatically
  455.      become an IMUG member.
  456.  
  457.  3.  Donate a pd widget, widget tool or widget builder to the IMUG Widget
  458.      Depository and receive a free one year IMUG membership.
  459.  
  460.  
  461. -----------------------------------------------------------------------------
  462. Subject: 149)  What is the X Professional Organization
  463.  
  464. [Last modified: JAN 02 1994]
  465.  
  466. Answer: The X Professional Organization's (XPO) purpose is to provide service
  467. to the X community.  It will serve as an information conduit for professional
  468. users of X.  XPO will participate in X activities, and help keep its members
  469. informed on X related issues.
  470.  
  471. http://
  472. In addition to the communication that professional organizations offer, XPO
  473. provides these other benefits to members:
  474.  
  475.     * subscription to the The X Resource, a quarterly publication
  476.       by O'Reilly & Associates, Inc.,
  477.  
  478.     * discounts on X related products, 20% off most new books
  479.  
  480. *** For a sample issue of the newsletter,
  481. *** email  XPO@DELPHI.COM and include your surface address:
  482.  
  483.     * the XPO quarterly newsletter featuring:
  484.          o highlights of conference activities,
  485.          o new product information,
  486.          o articles highlighting the latest innovations in X,
  487.          o feedback from developers and users of X,
  488.          o calendar of activities,
  489.          o forum for X professionals to interact and learn,
  490.          o and much more...
  491.  
  492. Membership Information:
  493. Annual pricing information in US dollars.
  494.  
  495. Associate:  Quarterly newsletter
  496. Regular: Quarterly newsletter + subscription to The X Resource
  497. Special: Regular + The X Resource  supplemental issues
  498.  
  499. Country               Associate    Regular     Special
  500. USA                     $35.00     $100.00     $120.00
  501. Canada & Mexico         $40.00     $105.00     $135.00
  502. Europe & Africa         $45.00     $125.00     $175.00
  503. Asia & Australia        $50.00     $130.00     $185.00
  504.  
  505.  
  506. Contact:  X Professional Organization, Post Office Box 78, Beltsville,
  507. Maryland, 20704  USA
  508.  
  509. phone: (301) 681 - 2230
  510. fax:   (410) 465 - 9918, email: XPO@DELPHI.COM
  511.  
  512. <A HREF= "http://nearnet.gnn.com/gnn/meta/internet/mkt/xpo/profile.html" XPO Company profile </a>
  513.  
  514.  
  515. -----------------------------------------------------------------------------
  516. Subject: 150)  How do I set the title of a top level window?
  517.  
  518. [Last modified: September 92]
  519.  
  520. Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
  521. (Note that this is of type String rather than XmStrin.) Ypu can also set
  522. XmNiconName if you want its icon to show this title.  For XmDialogShells, set
  523. the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
  524. subclass.  These can also be set in resource files.
  525.  
  526.  
  527. -----------------------------------------------------------------------------
  528. Subject: 151)  Can I use editres with Motif?
  529. [Last modified: January 93]
  530.  
  531. Answer: It isn't built in to Motif (at 1.2.0), but you can do this in your
  532. application
  533.  
  534.     extern void _XEditResCheckMessages();
  535.     ...
  536.     XtAddEventHandler(shell_widget, (EventMask)0, True,
  537.                         _XEditResCheckMessages, NULL);
  538.  
  539. once for each shell widget that you want to react to the "click to select
  540. client" protocol.  Then link your client with the R5 libXmu.
  541.  
  542. David Brooks, OSF
  543.  
  544. From Marc Quinton (quinton@stna7.stna7.stna.dgac.fr):
  545.  
  546. With X11R4 see the Editres package which is a port of the X11R5 Editres
  547. protocol and client. You can find it at :
  548.  
  549.  ftp.stna7.stna.dgac.fr(143.196.9.83):/pub/dist/Editres.tar.Z
  550.  
  551. -----------------------------------------------------------------------------
  552. Subject: 152)  How can I put decorations on transient windows using olwm?
  553.  
  554. Answer: From Jean-Philippe Martin-Flatin <syj@ecmwf.co.uk>
  555.  
  556. /**********************************************************************
  557. ** WindowDecorations.c
  558. **
  559. ** Manages window decorations under the OpenLook window manager (OLWM).
  560. **
  561. ** Adapted from a C++ program posted to comp.windows.x.motif by:
  562. **
  563. **    +--------------------------------------------------------------+
  564. **    | Ron Edmark                          User Interface Group     |
  565. **    | Tel:        (408) 980-1500 x282     Integrated Systems, Inc. |
  566. **    | Internet:   edmark@isi.com          3260 Jay St.             |
  567. **    | Voice mail: (408) 980-1590 x282     Santa Clara, CA 95054    |
  568. **    +--------------------------------------------------------------+
  569. ***********************************************************************/
  570.  
  571. #include <X11/X.h>
  572. #include <X11/Xlib.h>
  573. #include <X11/Xatom.h>
  574. #include <X11/Intrinsic.h>
  575. #include <X11/StringDefs.h>
  576. #include <X11/Protocols.h>
  577. #include <Xm/Xm.h>
  578. #include <Xm/AtomMgr.h>
  579.  
  580. /*
  581. ** Decorations for OpenLook:
  582. ** The caller can OR different mask options to change the frame decoration.
  583. */
  584. #define OLWM_Header     (long)(1<<0)
  585. #define OLWM_Resize     (long)(1<<1)
  586. #define OLWM_Close      (long)(1<<2)
  587.  
  588. /*
  589. ** Prototypes
  590. */
  591. static void InstallOLWMAtoms  (Widget w);
  592. static void AddOLWMDialogFrame(Widget widget, long decorationMask);
  593.  
  594.  
  595. /*
  596. ** Global variables
  597. */
  598. static Atom AtomWinAttr;
  599. static Atom AtomWTOther;
  600. static Atom AtomDecor;
  601. static Atom AtomResize;
  602. static Atom AtomHeader;
  603. static Atom AtomClose;
  604. static int  not_installed_yet = TRUE;
  605.  
  606.  
  607. static void InstallOLWMAtoms(Widget w)
  608. {
  609.         AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" ,    FALSE);
  610.         AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER",     FALSE);
  611.         AtomDecor   = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD",    FALSE);
  612.         AtomResize  = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
  613.         AtomHeader  = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
  614.         AtomClose   = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE",  FALSE);
  615.  
  616.         not_installed_yet = FALSE;
  617. }
  618.  
  619. static void AddOLWMDialogFrame(Widget widget, long decorationMask)
  620. {
  621.         Atom   winAttrs[2];
  622.         Atom   winDecor[3];
  623.         Widget shell = widget;
  624.         Window win;
  625.         int    numberOfDecorations = 0;
  626.  
  627.         /*
  628.         ** Make sure atoms for OpenLook are installed only once
  629.         */
  630.         if (not_installed_yet) InstallOLWMAtoms(widget);
  631.  
  632.         while (!XtIsShell(shell)) shell = XtParent(shell);
  633.  
  634.         win = XtWindow(shell);
  635.  
  636.         /*
  637.         ** Tell Open Look that our window is not one of the standard OLWM window        ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
  638.         */
  639.  
  640.         winAttrs[0] = AtomWTOther;
  641.  
  642.         XChangeProperty(XtDisplay(shell),
  643.                         win,
  644.                         AtomWinAttr,
  645.                         XA_ATOM,
  646.                         32,
  647.                         PropModeReplace,
  648.                         (unsigned char*)winAttrs,
  649.                         1);
  650.  
  651.         /*
  652.         ** Tell Open Look to add some decorations to our window
  653.         */
  654.         numberOfDecorations = 0;
  655.         if (decorationMask & OLWM_Header)
  656.                 winDecor[numberOfDecorations++] = AtomHeader;
  657.         if (decorationMask & OLWM_Resize)
  658.                 winDecor[numberOfDecorations++] = AtomResize;
  659.         if (decorationMask & OLWM_Close)
  660.         {
  661.                 winDecor[numberOfDecorations++] = AtomClose;
  662.  
  663.                 /*
  664.                 ** If the close button is specified, the header must be
  665.                 ** specified. If the header bit is not set, set it.
  666.                 */
  667.                 if (!(decorationMask & OLWM_Header))
  668.                         winDecor[numberOfDecorations++] = AtomHeader;
  669.         }
  670.  
  671.         XChangeProperty(XtDisplay(shell),
  672.                         win,
  673.                         AtomDecor,
  674.                         XA_ATOM,
  675.                         32,
  676.                         PropModeReplace,
  677.                         (unsigned char*)winDecor,
  678.                         numberOfDecorations);
  679. }
  680.  
  681.  
  682. /*
  683. ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
  684. */
  685. void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
  686. {
  687.         Atom atom;
  688.  
  689.         /*
  690.         ** Alias the "Close" item in system menu attached to dialog shell
  691.         ** to the activate callback of "Exit" in the menubar
  692.         */
  693.         if (Cbk_func)
  694.         {
  695.             atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
  696.             XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
  697.         }
  698.  
  699.         /*
  700.         ** If Motif is the window manager, skip OpenLook specific stuff
  701.         */
  702.         if (XmIsMotifWMRunning(shell)) return;
  703.  
  704.         /*
  705.         ** Register dialog shell to OpenLook.
  706.         **
  707.         ** WARNING: on some systems, adding the "Close" button allows the title
  708.         ** to be properly centered in the title bar. On others, activating
  709.         ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
  710.         ** the first case occurs with OpenWindows 2 while the second occurs with
  711.         ** Openwindows 3. Thus, comment out one of the two following lines as
  712.         ** suitable for your site, and send e-mail to syj@ecmwf.co.uk if you
  713.         ** find out what is going on !
  714.         */
  715.         AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
  716. /*      AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
  717. }
  718.  
  719.  
  720. -----------------------------------------------------------------------------
  721. Subject: 153)  Why does an augment translation appear to act as replace for
  722. some widgets?  When I use either augment or override translations in
  723. .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
  724.  
  725. Answer: By default, the translation table is NULL.  If there is nothing
  726. specified (either in resource file, or in args), the widget's Initialize
  727. finds: Oh, there is NULL in translations, lets use our default ones.  If,
  728. however, the translations have become non-NULL, the default translations are
  729. NOT used at all. Thus, using #augment, #override or a new table has identical
  730. effect: defines the new translations. The only way you can augment/override
  731. Motif's default translations is AFTER Initialize, using XtSetValues.  Note,
  732. however, that Motif managers do play with translation tables as well ... so
  733. that results are not always easy to predict.
  734.  
  735. From OSF: A number of people have complained about not being able to
  736. augment/override translations from the .Xdefaults.  This is due to the
  737. complexity of the menu system/keyboard traversal and the necessary
  738. translations changes required to support the Motif Style Guide in menus.  It
  739. cannot be fixed in a simple way. Fixing it requires re-design of the
  740. menus/buttons and it is planned to be fixed in 1.2.
  741.  
  742.  
  743.  
  744.  
  745.  
  746. -----------------------------------------------------------------------------
  747. Subject: 154)  How do you "grey" out a widget so that it cannot be activated?
  748.  
  749. Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
  750. resource directly yourself (by XtSetValues) since the widget may need to talk
  751. to parents first.
  752.  
  753.  
  754. -----------------------------------------------------------------------------
  755. Subject: 155)  Why doesn't the Help callback work on some widgets?
  756.  
  757. Answer: If you press the help key the help callback of the widget with the
  758. keyboard focus is called (not the one containing the mouse).  You can't get
  759. the help callback of a non-keyboard-selectable widget called. To get `context
  760. sensitive' help on these, you have to find the mouse, associate its position
  761. with a widget and then do the help.
  762.  
  763.  The X Resource, Issue 6, has an article on implementing context help in
  764.  Motif in this manner, that is, using the mouse position to indicate the
  765.  widget for which context help is desired, as well as using resources to
  766.  specify the help.  Example source code is available at
  767.  
  768.          ftp.uu.net:/published/oreilly/xresource/helpdemo.tar.Z
  769.  
  770.  The demo program lets you toggle between using the method described in
  771.  the article and XmTrackingLocate() for comparision purposes.
  772.  
  773. contributed by: Jay Schmidgall  jay@vnet.ibm.com (author of the article
  774. mentioned above) --
  775.  
  776.  
  777.  
  778. -----------------------------------------------------------------------------
  779. Subject: 156)  Where can I get a Table widget?
  780.  
  781. [Last modified: December 92]
  782.  
  783. Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of
  784. his table widget.  The Widget Creation Library also has one.  See under Motif
  785. prototyping tools for the contact.
  786.  
  787. Expert Database Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280.
  788. Phone: (212) 783-6981 has a very comprehensive table widget that uses both
  789. motif scrollbars or a "virtual" scrollbar showing a miniature version of the
  790. entire spreadsheet. Allows for different width columns, changing colors in
  791. each cell.  Only one X-Window is used so as to reduce the amount of system
  792. resources used.  Contact Ken Jones email: ken@mr_magoo.sbi.com)
  793.  
  794.  
  795. -----------------------------------------------------------------------------
  796. Subject: 157)  Has anyone done a bar graph widget?
  797. [Last modified: September 92]
  798.  
  799. Answer: You can fake one by using for each bar a scroll bar or even a label
  800. which changes in size, put inside a container of some kind.
  801.  
  802. Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
  803. to 0 to keep it from automatically updating.
  804.  
  805. The comp.windows.x FAQ mentions a bar graph widget.
  806.  
  807. Expert Database Systems, Inc.  sells a bar graph widget as well as a multi-
  808. line graph with automatic scaling, a 3-D surface graph, and a high/Low graph
  809. with two lines for moving averages.  Contact Ken Jones Expert Database
  810. Systems, Inc., 377 Rector Place, Suite 3L New York, NY 10280.  Phone: (212)
  811. 783-6981
  812.  
  813.  
  814. The Xtra XWidget library contains a set of widgets that are subclassed from
  815. and compatible with either OSF/Motif or OLIT widgets.  The library includes
  816. widgets that implement the following:
  817.  
  818.    Spreadsheet
  819.    Bar Graph
  820.    Stacked Bar Graph
  821.    Line Graph
  822.    Pie Chart
  823.    XY Plot
  824.    Hypertext
  825.    Hypertext based Help System
  826.    Entry Form with type checking
  827.  
  828. Contact Graphical Software Technology at 310-328-9338  (info@gst.com) for
  829. information.
  830.  
  831. The XRT/graph widget, available for Motif, XView and OLIT, displays X-Y plots,
  832. bar and pie charts, and supports user-feedback, fast updates and PostScript
  833. output. Contact KL Group Inc. at 416-594-1026 (xrt_info%klg@uunet.ca)
  834.  
  835. The product Xmath, made by Integrated Systems Inc. is a product which has
  836. interactive 2d and 3d graphics for bar,strip,line,symbol,
  837. surface,contour,etc... that costs $2500.00 for commercial use and a mere
  838. $250.00 for university use that also has complete numerics capabilities, an
  839. easy to use debugger, a complete high level language, a spreadsheet, a motif
  840. gui access capability, and much more all created on top of motif.
  841.  
  842. You can either email to xmath-info@isi.com or call (408)980-1500.
  843.  
  844. Digital Equipment Corporation (DEC) provides the following product NetEd: "The
  845. network editor widget is a Motif toolkit conforming widget that applications
  846. can use to express complex interrelationships graphically in the form of
  847. networks or graphs. The network editor supports interactive or application-
  848. controlled creation and editing of directed graphs or networks."
  849.  
  850.  
  851. ACE/gr is an X based XY plotting tool implemented with a point 'n click
  852. paradigm.  A few of its features are:
  853.  
  854.    * Plots up to 10 graphs with 30 data sets per graph.
  855.    * Data read from files and/or pipes.
  856.    * Graph types XY, log-linear, linear-log, log-log, bar,
  857.         stacked bar charts.
  858.  
  859. it is available from
  860.  
  861.         ftp.ccalmr.ogi.edu (presently amb4.ccalmr.ogi.edu)
  862.  
  863. with IP address 129.95.72.34. The XView version (xvgr) will be found in
  864. /CCALMR/pub/acegr/xvgr-2.09.tar.Z and the Motif version (xmgr) in
  865. /CCALMR/pub/acegr/xmgr-2.09.tar.Z.  Comments, suggestions, bug reports to
  866. pturner@amb4.ccalmr.ogi.edu (if mail fails, try pturner@ese.ogi.edu). Due to
  867. time constraints, replies will be few and far between.
  868.  
  869.  
  870.  
  871. -----------------------------------------------------------------------------
  872. Subject: 158)  Does anyone know of a source code of a graph widget where you
  873. can add vertices and edges and get an automated updating?
  874.  
  875. [Last modified: March 93]
  876.  
  877. Answer: The XUG FAQ in comp.windows.x includes information on graph display
  878. widgets.  There is also an implementation in the Asente/Swick book.
  879.  
  880.   From Martin Janzen: "You could have a look at DataViews, from V.I.
  881.    Corporation.  This package is used mainly to display a variety of graph
  882.    drawings (eg. bar, line, pie, high/low, and other charts), and to update
  883.    the graphs as information is received from "data sources" such as files,
  884.    processes (through pipes), or devices.
  885.  
  886.    However, it also provides "node" and "edge" objects which can be used
  887.    when working with network graphs.  The DV-Tools function library
  888.    provides routines which traverse a graph, count visits to each node or
  889.    edge, mark nodes or edges of interest, and so on.  A node or edge object
  890.    can have an associated "geometry object" (such as a symbol or a line),
  891.    which represents that node or edge.
  892.  
  893.    Drawbacks: There's no automatic positioning algorithm; when you add a
  894.    node or edge, you have to create and position its geometry object
  895.    yourself.  Also, this isn't a set of add-on widgets; you can either have
  896.    DataViews create an X window (ie. a separate shell), or you can create
  897.    your own XmDrawingArea and use DataViews to update its window when
  898.    expose events are received.  Finally, the package is quite expensive,
  899.    and there is a run-time charge.
  900.  
  901.    The vendor's address is:
  902.      V.I. Corporation,
  903.      47 Pleasant Street,
  904.      Northampton, MA  01060,
  905.             Email: vi@vicorp.com, Phone: (413) 586-4144, Fax:   (413) 584-2649
  906.  
  907.    or
  908.  
  909.      V.I. Corporation (Europe) Ltd.,
  910.      First Base, Beacontree Plaza,
  911.      Gillette Way,                      Email: viesales@eurovi.uucp
  912.      Reading, Berkshire  RG2 0BP"
  913.    Phone: +44 734 756010,      Fax:   +44 734 756104
  914.  
  915. From Craig Timmerman: Just wanted others to know that there is a third
  916. competitor in what may be come a big market for generic APIs.  The product is
  917. called Open Interface and Neuron Data is the vendor.  Neuron has added some
  918. extra, more complex widgets to their set.  The two most notable are a table
  919. and network widget.  [...] I believe that the network widget got its name from
  920. its ability to display expert system networks that Neuron's AI tools needed.
  921. It would be more aptly named the graph widget.  It can display and manipulate
  922. graphs of various types (trees, directed graphs, etc).  Contact is
  923.  
  924.         Neuron Data
  925.         156 University Avenue
  926.         Palo Alto,  CA  94301
  927.         (415) 321-4488
  928.  
  929.  
  930. prism!gt3273b@gatech.edu  (RENALDS,ANDREW THEODORE) posted a set of public
  931. domain routines for graph drawing.  Contact him for a later set.
  932.  
  933. From Ramon Santiago (santiago@fgssu1.fgs.slb.com): HP has released source code
  934. for XmGraph and XmArc, part of the InterWorks library, which does exactly
  935. this. The sources can be obtained by contacting Dave Shaw,
  936. librarian@iworks.ecn.uiowa.edu. A few trivial source code changes need to be
  937. made to get these widgets to compile under Motif 1.2.
  938.  
  939. Free DAG - directed acyclic graph drawing software in motif environment is
  940. available. Please send a note to address below if you want it:
  941.  
  942. Budak Arpinar, TUBITAK Software Research & Development Center, Ankara,
  943. TURKIYE, E-mail : C51881@TRMETU.BITNET
  944.  
  945.  
  946.  
  947. -----------------------------------------------------------------------------
  948. Subject: 159)+ Is there a help system available, such as in Windows 3?  Or any
  949. Motif based hypertext system.
  950.  
  951. [Last modified: apr 94]
  952.  
  953. Answer:
  954.  
  955. HTML Widget from NCSA:
  956.  
  957. The NCSA Mosaic for X package contains a html widget which is freely available
  958. and is the main vehicle for viewing html documents in the Mosaic program. It
  959. has callbacks for anchor hits, selections, etc and many many resources for
  960. customizing the viewing area of your hypertext documents.
  961.  
  962. GWHIS:
  963.  
  964. There is a new product from Quadralay Corporation, called the Global-Wide Help
  965. & Information Systems (GWHIS).
  966.  
  967. from a press release: AUSTIN, TX (March 3, 1994) Quadralay Corporation today
  968. announced its newest software development tool, Global Wide Help & Information
  969. System (GWHIS).  GWHIS allows third party application developers to add online
  970. documentation and context sensitive help to their applications like never
  971. before.  This documentation may consist of plain text, rich format text,
  972. hypertext, images, audio, and/or video animation and may easily be distributed
  973. either locally or over a wide area network such as the Internet.
  974.  
  975. GWHIS consists of two primary components.  An application programming
  976. interface (API), and a hypermedia viewer (based on technology licensed from
  977. the NCSA Mosaic project).  Several ancillary conversion programs are also
  978. available allowing end users to easily convert existing documentation into
  979. GWHIS' native HTML format.
  980.  
  981. GWHIS is available on the following platforms: SPARC SunOS 4.1.x, SPARC
  982. Solaris 2.x, INTEL SCO Open Desktop, INTEL Solaris 2.x, HP 9000/700, and the
  983. RS/6000. Support for additional platforms (including MS Windows and Macintosh)
  984. is under consideration.  Fully functional evaluation copies of this software
  985. are available upon request or via anonymous ftp from ftp.quadralay.com.
  986.  
  987. Brian Combs Quadralay Corporation combs@quadralay.com
  988.  
  989.  
  990.  
  991. Bristol Technology have a hypertext system HyperHelp with the look-and-feel of
  992. either Motif or OpenLook. It should be available from january 31, 1992.
  993. Contact
  994.  
  995.         Bristol Technology Inc.
  996.         898 Ethan Allen Highway
  997.         Ridgefield, CT  06877
  998.         203-438-6969 (phone)
  999.         203-438-5013 (fax)
  1000.         uunet.uu.net!bristol!keith
  1001.  
  1002. Demos are available by anonymous ftp from  ftp.uu.net (137.39.1.9) in the
  1003. vendor/Bristol/HyperHelp as files sun.motif.tar.Z and hp.tar.Z.
  1004.  
  1005. There was a posting of a motif hypertext-widget to comp.sources.x (Author:
  1006. B.Raoult ( mab@ecmwf.co.uk ) ).  It had the facility to read in helptext from
  1007. a file.
  1008.  
  1009. From Francois Felix Ingrand (felix@idefix.laas.fr): I have translated the Info
  1010. AW (originally written by Jordan Hubbard) to Motif. It is a Widget to browse
  1011. Info files (format used by GNU for their various documentations). I use it as
  1012. the help system of various tool I wrote.  It is available on laas.laas.fr
  1013. (140.93.0.15) in /pub/prs/xinfo-motif.tar.Z
  1014.  
  1015. Form Scott Raney (raney@metacard.com) MetaCard is a commercial package that
  1016. can be used to implement hypertext help.  The text fields support multiple
  1017. typefaces, sizes, styles, colors, subscript/superscript, and hypertext links.
  1018. It has a Motif interface, and a template for calling it from an Xt/Motif
  1019. application is included.  You can FTP a save-disabled distribution from
  1020. ftp.metacard.com or from world.std.com.  For more info, email to
  1021. info@metacard.com.
  1022.  
  1023.  
  1024. The Motifation GbR also provides a hypertext-helpsystem named 'XpgHelp'.
  1025. (Motif look-and-feel / features like those known from MS Windows Help ) For a
  1026. free demo or more information send email either to griebel@uni-paderborn.d e
  1027. or contact the distributor:
  1028.  
  1029.         PEM GmbH,
  1030.         Vaihinger Strasse 49,
  1031.         7000 Stuttgart 80,
  1032.         Germany,
  1033.         +49 (0) 711 713045 (phone),
  1034.         +49 (0) 711 713047 (fax),
  1035.         email: basien@pem-stuttgart.de
  1036.  
  1037. XpgHelp has nearly the same features like HyperHelp: (multiple fonts, graphics
  1038. in b&w and color, different styles, tabs, links, short links, notepad, ...)
  1039.  
  1040. The Interface Builder MOTIFATION uses XpgHelp as its hypertext helpsystem.
  1041.  
  1042.  
  1043.  
  1044. -----------------------------------------------------------------------------
  1045. Subject: 160)  Can I specify a widget in a resource file?
  1046.  
  1047. Answer: This answer, which uses the Xmu library, is due to David Elliott.  If
  1048. the converter is added, then the name of a widget (a string) can be used in
  1049. resource files, and will be converted to the appropriate widget.
  1050.  
  1051. This code, which was basically stolen from the Athena Form widget, adds a
  1052. String to Widget converter.  I wrote it as a general routine that I call at
  1053. the beginning of all of my programs, and made it so I could add other
  1054. converters as needed (like String to Unit Type ;-).
  1055.  
  1056.         #include <X11/Intrinsic.h>
  1057.         #include <X11/StringDefs.h>
  1058.         #include <Xm/Xm.h>
  1059.         #include <X11/Xmu/Converters.h>
  1060.         #include <X11/IntrinsicP.h>
  1061.         #include <X11/CoreP.h>
  1062.  
  1063.         void
  1064.         setupConverters()
  1065.         {
  1066.                 static XtConvertArgRec parentCvtArgs[] = {
  1067.                         {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
  1068.                                 sizeof(Widget)}
  1069.                 };
  1070.  
  1071.                 XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
  1072.                         parentCvtArgs, XtNumber(parentCvtArgs));
  1073.         }
  1074.  
  1075.  
  1076.  
  1077. -----------------------------------------------------------------------------
  1078. Subject: 161)  Why are only some of my translations are being installed?  I
  1079. have a translation table like the following, but only the first ones are
  1080. getting installed and the rest are ignored.
  1081.  
  1082.  *Text.translations:    #override \
  1083.      Ctrl<Key>a:    beginning-of-line() \n\
  1084.      Ctrl<Key>e:    end-of-line() \n\
  1085.      Ctrl<Key>f:    forward-character() \n\
  1086.  
  1087.  
  1088. Answer: Most likely, you have a space at the end of one of the lines (the
  1089. first in this case).
  1090.  
  1091.      Ctrl<Key>a:    beginning-of-line() \n\
  1092.                                            ^ space here
  1093.  
  1094. The second backslash in each line is there to protect the real newline
  1095. character and so you must not follow it with anything other than the newline
  1096. itself. Otherwise it acts as the end of the resource definition and the
  1097. remaining lines are not added.
  1098.  
  1099.  
  1100. -----------------------------------------------------------------------------
  1101. Subject: 162)  Where can I get the PanHandler code?
  1102.  
  1103. Answer: It is available by email from Chuck Ocheret:  chuck@IMSI.COM.
  1104.  
  1105. -----------------------------------------------------------------------------
  1106. Subject: 163)  What are these passive grab warnings?  When I destroy certain
  1107. widgets I get a stream of messages
  1108.  
  1109.     Warning: Attempt to remove non-existant passive grab
  1110.  
  1111.  
  1112. Answer: They are meaningless, and you want to ignore them.  Do this (from Kee
  1113. Hinckley) by installing an XtWarning handler that explicitly looks for them
  1114. and discards them:
  1115.  
  1116.         static void xtWarnCB(String message) {
  1117.            if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
  1118.            ...
  1119.  
  1120. They come from Xt, and (W. Scott Meeks): "it's something that the designers of
  1121. Xt decided the toolkit should do. Unfortunately, Motif winds up putting
  1122. passive grabs all over the place for the menu system.  On the one hand, we
  1123. want to remove all these grabs when menus get destroyed so that they don't
  1124. leak memory; on the other hand, it's almost impossible to keep track of all
  1125. the grabs, so we have a conservative strategy of ungrabbing any place where a
  1126. grab could have been made and we don't explicitly know that there is no grab.
  1127. The unfortunate side effect is the little passive grab warning messages.
  1128. We're trying to clean these up where possible, but there are some new places
  1129. where the warning is generated.  Until we get this completely cleaned up (1.2
  1130. maybe), your best bet is probably to use a warning handler."
  1131.  
  1132. -----------------------------------------------------------------------------
  1133. Subject: 164)  How do I have more buttons than three in a box?  I want to have
  1134. something like a MessageBox (or other widget) with more than three buttons,
  1135. but with the same nice appearance.
  1136.  
  1137. [Last modified: May 93]
  1138.  
  1139. Answer: The Motif 1.2 MessageBox widget allows extra buttons to be added after
  1140. the OK button. Just create the extra buttons as children of the MessageBox.
  1141. Similarly with the SelectionBox.
  1142.  
  1143. Pre-Motif 1.2, you have to do one of the following methods.
  1144.  
  1145. A SelectionBox is created with four buttons, but the fourth (the Apply button)
  1146. is unmanaged. To manage it get its widget ID via
  1147. XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
  1148. Unmanage all of the other bits in the SelectionBox that you don't want.  If
  1149. you want more than four buttons, try two SelectionBoxes (or similar) together
  1150. in a container, where all of the unwanted parts of the widgets are unmanaged.
  1151.  
  1152. Alternatively, build your own dialog:
  1153.  
  1154. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1155.  * This program is freely distributable without licensing fees and
  1156.  * is provided without guarantee or warranty expressed or implied.
  1157.  * This program is -not- in the public domain.  This program is
  1158.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  1159.  */
  1160.  
  1161. /* action_area.c -- demonstrate how CreateActionArea() can be used
  1162.  * in a real application.  Create what would otherwise be identified
  1163.  * as a PromptDialog, only this is of our own creation.  As such,
  1164.  * we provide a TextField widget for input.  When the user presses
  1165.  * Return, the Ok button is activated.
  1166.  */
  1167. #include <Xm/DialogS.h>
  1168. #include <Xm/PushBG.h>
  1169. #include <Xm/PushB.h>
  1170. #include <Xm/LabelG.h>
  1171. #include <Xm/PanedW.h>
  1172. #include <Xm/Form.h>
  1173. #include <Xm/RowColumn.h>
  1174. #include <Xm/TextF.h>
  1175.  
  1176. typedef struct {
  1177.     char *label;
  1178.     void (*callback)();
  1179.     caddr_t data;
  1180. } ActionAreaItem;
  1181.  
  1182. static void
  1183.     do_dialog(), close_dialog(), activate_cb(),
  1184.     ok_pushed(), cancel_pushed(), help();
  1185.  
  1186. main(argc, argv)
  1187. int argc;
  1188. char *argv[];
  1189. {
  1190.     Widget toplevel, button;
  1191.     XtAppContext app;
  1192.  
  1193.     toplevel = XtVaAppInitialize(&app, "Demos",
  1194.         NULL, 0, &argc, argv, NULL, NULL);
  1195.  
  1196.     button = XtVaCreateManagedWidget("Push Me",
  1197.         xmPushButtonWidgetClass, toplevel, NULL);
  1198.     XtAddCallback(button, XmNactivateCallback, do_dialog, NULL);
  1199.  
  1200.     XtRealizeWidget(toplevel);
  1201.     XtAppMainLoop(app);
  1202. }
  1203.  
  1204. /* callback routine for "Push Me" button.  Actually, this represents
  1205.  * a function that could be invoked by any arbitrary callback.  Here,
  1206.  * we demonstrate how one can build a standard customized dialog box.
  1207.  * The control area is created here and the action area is created in
  1208.  * a separate, generic routine: CreateActionArea().
  1209.  */
  1210. static void
  1211. do_dialog(w, file)
  1212. Widget w; /* will act as dialog's parent */
  1213. char *file;
  1214. {
  1215.     Widget dialog, pane, rc, label, text_w, action_a;
  1216.     XmString string;
  1217.     extern Widget CreateActionArea();
  1218.     Arg args[10];
  1219.     static ActionAreaItem action_items[] = {
  1220.         { "Ok",     ok_pushed,     NULL          },
  1221.         { "Cancel", cancel_pushed, NULL          },
  1222.         { "Close",  close_dialog,  NULL          },
  1223.         { "Help",   help,          "Help Button" },
  1224.     };
  1225.  
  1226.     /* The DialogShell is the Shell for this dialog.  Set it up so
  1227.      * that the "Close" button in the window manager's system menu
  1228.      * destroys the shell (it only unmaps it by default).
  1229.      */
  1230.     dialog = XtVaCreatePopupShell("dialog",
  1231.         xmDialogShellWidgetClass, XtParent(w),
  1232.         XmNtitle,  "Dialog Shell",     /* give arbitrary title in wm */
  1233.         XmNdeleteResponse, XmDESTROY,  /* system menu "Close" action */
  1234.         NULL);
  1235.  
  1236.     /* now that the dialog is created, set the Close button's
  1237.      * client data, so close_dialog() will know what to destroy.
  1238.      */
  1239.     action_items[2].data = (caddr_t)dialog;
  1240.  
  1241.     /* Create the paned window as a child of the dialog.  This will
  1242.      * contain the control area (a Form widget) and the action area
  1243.      * (created by CreateActionArea() using the action_items above).
  1244.      */
  1245.     pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
  1246.         XmNsashWidth,  1,
  1247.         XmNsashHeight, 1,
  1248.         NULL);
  1249.  
  1250.     /* create the control area (Form) which contains a
  1251.      * Label gadget and a List widget.
  1252.      */
  1253.     rc = XtVaCreateWidget("control_area", xmRowColumnWidgetClass, pane, NULL);
  1254.     string = XmStringCreateSimple("Type Something:");
  1255.     XtVaCreateManagedWidget("label", xmLabelGadgetClass, rc,
  1256.         XmNlabelString,    string,
  1257.         XmNleftAttachment, XmATTACH_FORM,
  1258.         XmNtopAttachment,  XmATTACH_FORM,
  1259.         NULL);
  1260.     XmStringFree(string);
  1261.  
  1262.     text_w = XtVaCreateManagedWidget("text-field",
  1263.         xmTextFieldWidgetClass, rc, NULL);
  1264.  
  1265.     /* RowColumn is full -- now manage */
  1266.     XtManageChild(rc);
  1267.  
  1268.     /* Set the client data "Ok" and "Cancel" button's callbacks. */
  1269.     action_items[0].data = (caddr_t)text_w;
  1270.     action_items[1].data = (caddr_t)text_w;
  1271.  
  1272.     /* Create the action area -- we don't need the widget it returns. */
  1273.     action_a = CreateActionArea(pane, action_items, XtNumber(action_items));
  1274.  
  1275.     /* callback for Return in TextField.  Use action_a as client data */
  1276.     XtAddCallback(text_w, XmNactivateCallback, activate_cb, action_a);
  1277.  
  1278.     XtManageChild(pane);
  1279.     XtPopup(dialog, XtGrabNone);
  1280. }
  1281.  
  1282. /*--------------*/
  1283. /* The next four functions are the callback routines for the buttons
  1284.  * in the action area for the dialog created above.  Again, they are
  1285.  * simple examples, yet they demonstrate the fundamental design approach.
  1286.  */
  1287. static void
  1288. close_dialog(w, shell)
  1289. Widget w, shell;
  1290. {
  1291.     XtDestroyWidget(shell);
  1292. }
  1293.  
  1294. /* The "ok" button was pushed or the user pressed Return */
  1295. static void
  1296. ok_pushed(w, text_w, cbs)
  1297. Widget w, text_w;         /* the text widget is the client data */
  1298. XmAnyCallbackStruct *cbs;
  1299. {
  1300.     char *text = XmTextFieldGetString(text_w);
  1301.  
  1302.     printf("String = %s0, text);
  1303.     XtFree(text);
  1304. }
  1305.  
  1306. static void
  1307. cancel_pushed(w, text_w, cbs)
  1308. Widget w, text_w;         /* the text field is the client data */
  1309. XmAnyCallbackStruct *cbs;
  1310. {
  1311.     /* cancel the whole operation; reset to NULL. */
  1312.     XmTextFieldSetString(text_w, "");
  1313. }
  1314.  
  1315. static void
  1316. help(w, string)
  1317. Widget w;
  1318. String string;
  1319. {
  1320.     puts(string);
  1321. }
  1322. /*--------------*/
  1323.  
  1324. /* When Return is pressed in TextField widget, respond by getting
  1325.  * the designated "default button" in the action area and activate
  1326.  * it as if the user had selected it.
  1327.  */
  1328. static void
  1329. activate_cb(text_w, client_data, cbs)
  1330. Widget text_w;              /* user pressed Return in this widget */
  1331. XtPointer client_data;        /* action_area passed as client data */
  1332. XmAnyCallbackStruct *cbs;   /* borrow the "event" field from this */
  1333. {
  1334.     Widget dflt, action_area = (Widget)client_data;
  1335.  
  1336.     XtVaGetValues(action_area, XmNdefaultButton, &dflt, NULL);
  1337.     if (dflt) /* sanity check -- this better work */
  1338.         /* make the default button think it got pushed.  This causes
  1339.          * "ok_pushed" to be called, but XtCallActionProc() causes
  1340.          * the button appear to be activated as if the user selected it.
  1341.          */
  1342.         XtCallActionProc(dflt, "ArmAndActivate", cbs->event, NULL, 0);
  1343. }
  1344.  
  1345. #define TIGHTNESS 20
  1346.  
  1347. Widget
  1348. CreateActionArea(parent, actions, num_actions)
  1349. Widget parent;
  1350. ActionAreaItem *actions;
  1351. int num_actions;
  1352. {
  1353.     Widget action_area, widget;
  1354.     int i;
  1355.  
  1356.     action_area = XtVaCreateWidget("action_area", xmFormWidgetClass, parent,
  1357.         XmNfractionBase, TIGHTNESS*num_actions - 1,
  1358.         XmNleftOffset,   10,
  1359.         XmNrightOffset,  10,
  1360.         NULL);
  1361.  
  1362.     for (i = 0; i < num_actions; i++) {
  1363.         widget = XtVaCreateManagedWidget(actions[i].label,
  1364.             xmPushButtonWidgetClass, action_area,
  1365.             XmNleftAttachment,       i? XmATTACH_POSITION : XmATTACH_FORM,
  1366.             XmNleftPosition,         TIGHTNESS*i,
  1367.             XmNtopAttachment,        XmATTACH_FORM,
  1368.             XmNbottomAttachment,     XmATTACH_FORM,
  1369.             XmNrightAttachment,
  1370.                     i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
  1371.             XmNrightPosition,        TIGHTNESS*i + (TIGHTNESS-1),
  1372.             XmNshowAsDefault,        i == 0,
  1373.             XmNdefaultButtonShadowThickness, 1,
  1374.             NULL);
  1375.         if (actions[i].callback)
  1376.             XtAddCallback(widget, XmNactivateCallback,
  1377.                 actions[i].callback, actions[i].data);
  1378.         if (i == 0) {
  1379.             /* Set the action_area's default button to the first widget
  1380.              * created (or, make the index a parameter to the function
  1381.              * or have it be part of the data structure). Also, set the
  1382.              * pane window constraint for max and min heights so this
  1383.              * particular pane in the PanedWindow is not resizable.
  1384.              */
  1385.             Dimension height, h;
  1386.             XtVaGetValues(action_area, XmNmarginHeight, &h, NULL);
  1387.             XtVaGetValues(widget, XmNheight, &height, NULL);
  1388.             height += 2 * h;
  1389.             XtVaSetValues(action_area,
  1390.                 XmNdefaultButton, widget,
  1391.                 XmNpaneMaximum,   height,
  1392.                 XmNpaneMinimum,   height,
  1393.                 NULL);
  1394.         }
  1395.     }
  1396.  
  1397.     XtManageChild(action_area);
  1398.  
  1399.     return action_area;
  1400. }
  1401.  
  1402.  
  1403.  
  1404. -----------------------------------------------------------------------------
  1405. Subject: 165)  How do I create a "busy working cursor"?
  1406.  
  1407. Answer: - in Baudouin's code (following), the idea is to keep in an array an
  1408. up-to-date list of all shells used in the application, and set for all of them
  1409. the cursor to a watch or to the default cursor, with the 2 functions provided.
  1410.  
  1411. - in Dan Heller's code (later), the idea is to turn on the watch cursor for
  1412. the top-level shell only, popup a working window to possibly abort the
  1413. callback, and manage some expose events during the callback.
  1414.  
  1415. - in the FAQ for comp.windows.x (#113), the idea is to bring a large window on
  1416. top of the application, hide all windows below it, and turn on the watch
  1417. cursor on this large window. Unmapping the large window resets the default
  1418. cursor, mapping it turns on the watch cursor.
  1419.  
  1420. From Baudouin Raoult (mab@ecmwf.co.uk)
  1421.  
  1422. void my_SetWatchCursor(w)
  1423. Widget w;
  1424. {
  1425.         static Cursor watch = NULL;
  1426.  
  1427.         if(!watch)
  1428.                 watch = XCreateFontCursor(XtDisplay(w),XC_watch);
  1429.  
  1430.         XDefineCursor(XtDisplay(w),XtWindow(w),watch);
  1431.         XmUpdateDisplay(w);
  1432. }
  1433.  
  1434. void my_ResetCursor(w)
  1435. Widget w;
  1436. {
  1437.         XUndefineCursor(XtDisplay(w),XtWindow(w));
  1438.         XmUpdateDisplay(w);
  1439. }
  1440.  
  1441.  
  1442. Answer: A solution with lots of bells and whistles is
  1443.  
  1444. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1445.  * This program is freely distributable without licensing fees and
  1446.  * is provided without guarantee or warrantee expressed or implied.
  1447.  * This program is -not- in the public domain.
  1448.  */
  1449.  
  1450. /* busy.c -- demonstrate how to use a WorkingDialog and to process
  1451.  * only "important" events.  e.g., those that may interrupt the
  1452.  * task or to repaint widgets for exposure.  Set up a simple shell
  1453.  * and a widget that, when pressed, immediately goes into its own
  1454.  * loop.  First, "lock" the shell so that a timeout cursor is set on
  1455.  * the shell and pop up a WorkingDialog.  Then enter loop ... sleep
  1456.  * for one second ten times, checking between each interval to see
  1457.  * if the user clicked the Stop button or if any widgets need to be
  1458.  * refreshed.  Ignore all other events.
  1459.  *
  1460.  * main() and get_busy() are stubs that would be replaced by a real
  1461.  * application; all other functions can be used "as is."
  1462.  */
  1463. #include <Xm/MessageB.h>
  1464. #include <Xm/PushB.h>
  1465. #include <X11/cursorfont.h>
  1466.  
  1467. Widget shell;
  1468. void TimeoutCursors();
  1469. Boolean CheckForInterrupt();
  1470.  
  1471. main(argc, argv)
  1472. int argc;
  1473. char *argv[];
  1474. {
  1475.     XtAppContext app;
  1476.     Widget button;
  1477.     XmString label;
  1478.     void get_busy();
  1479.  
  1480.     shell = XtVaAppInitialize(&app, "Demos",
  1481.         NULL, 0, &argc, argv, NULL, NULL);
  1482.  
  1483.     label = XmStringCreateSimple(
  1484.         "Boy, is *this* going to take a long time.");
  1485.     button = XtVaCreateManagedWidget("button",
  1486.         xmPushButtonWidgetClass, shell,
  1487.         XmNlabelString,          label,
  1488.         NULL);
  1489.     XmStringFree(label);
  1490.     XtAddCallback(button, XmNactivateCallback, get_busy, argv[1]);
  1491.  
  1492.     XtRealizeWidget(shell);
  1493.     XtAppMainLoop(app);
  1494. }
  1495.  
  1496. void
  1497. get_busy(widget)
  1498. Widget widget;
  1499. {
  1500.     int n;
  1501.  
  1502.     TimeoutCursors(True, True);
  1503.     for (n = 0; n < 10; n++) {
  1504.         sleep(1);
  1505.         if (CheckForInterrupt()) {
  1506.             puts("Interrupt!");
  1507.             break;
  1508.         }
  1509.     }
  1510.     if (n == 10)
  1511.         puts("done.");
  1512.     TimeoutCursors(False, NULL);
  1513. }
  1514.  
  1515. /* The interesting part of the program -- extract and use at will */
  1516. static Boolean stopped;  /* True when user wants to stop processing */
  1517. static Widget dialog;    /* WorkingDialog displayed when timed out */
  1518.  
  1519. /* timeout_cursors() turns on the "watch" cursor over the application
  1520.  * to provide feedback for the user that he's going to be waiting
  1521.  * a while before he can interact with the appliation again.
  1522.  */
  1523. void
  1524. TimeoutCursors(on, interruptable)
  1525. int on, interruptable;
  1526. {
  1527.     static int locked;
  1528.     static Cursor cursor;
  1529.     extern Widget shell;
  1530.     XSetWindowAttributes attrs;
  1531.     Display *dpy = XtDisplay(shell);
  1532.     XEvent event;
  1533.     Arg args[1];
  1534.     XmString str;
  1535.     extern void stop();
  1536.  
  1537.     /* "locked" keeps track if we've already called the function.
  1538.      * This allows recursion and is necessary for most situations.
  1539.      */
  1540.     on? locked++ : locked--;
  1541.     if (locked > 1 || locked == 1 && on == 0)
  1542.         return; /* already locked and we're not unlocking */
  1543.  
  1544.     stopped = False; /* doesn't matter at this point; initialize */
  1545.     if (!cursor) /* make sure the timeout cursor is initialized */
  1546.         cursor = XCreateFontCursor(dpy, XC_watch);
  1547.  
  1548.     /* if "on" is true, then turn on watch cursor, otherwise, return
  1549.      * the shell's cursor to normal.
  1550.      */
  1551.     attrs.cursor = on? cursor : None;
  1552.  
  1553.     /* change the main application shell's cursor to be the timeout
  1554.      * cursor (or to reset it to normal).  If other shells exist in
  1555.      * this application, they will have to be listed here in order
  1556.      * for them to have timeout cursors too.
  1557.      */
  1558.     XChangeWindowAttributes(dpy, XtWindow(shell), CWCursor, &attrs);
  1559.  
  1560.     XFlush(dpy);
  1561.  
  1562.     if (on) {
  1563.         /* we're timing out, put up a WorkingDialog.  If the process
  1564.          * is interruptable, allow a "Stop" button.  Otherwise, remove
  1565.          * all actions so the user can't stop the processing.
  1566.          */
  1567.         str = XmStringCreateSimple("Busy.  Please Wait.");
  1568.         XtSetArg(args[0], XmNmessageString, str);
  1569.         dialog = XmCreateWorkingDialog(shell, "Busy", args, 1);
  1570.         XmStringFree(str);
  1571.         XtUnmanageChild(
  1572.             XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
  1573.         if (interruptable) {
  1574.             str = XmStringCreateSimple("Stop");
  1575.             XtVaSetValues(dialog, XmNcancelLabelString, str, NULL);
  1576.             XmStringFree(str);
  1577.             XtAddCallback(dialog, XmNcancelCallback, stop, NULL);
  1578.         } else
  1579.             XtUnmanageChild(
  1580.                 XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
  1581.         XtUnmanageChild(
  1582.             XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
  1583.         XtManageChild(dialog);
  1584.     } else {
  1585.         /* get rid of all button and keyboard events that occured
  1586.          * during the time out.  The user shouldn't have done anything
  1587.          * during this time, so flush for button and keypress events.
  1588.          * KeyRelease events are not discarded because accelerators
  1589.          * require the corresponding release event before normal input
  1590.          * can continue.
  1591.          */
  1592.         while (XCheckMaskEvent(dpy,
  1593.                 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
  1594.                 | PointerMotionMask | KeyPressMask, &event)) {
  1595.             /* do nothing */;
  1596.         }
  1597.         XtDestroyWidget(dialog);
  1598.     }
  1599. }
  1600.  
  1601. /* User Pressed the "Stop" button in dialog. */
  1602. void
  1603. stop(dialog)
  1604. Widget dialog;
  1605. {
  1606.     stopped = True;
  1607. }
  1608.  
  1609. Boolean
  1610. CheckForInterrupt()
  1611. {
  1612.     extern Widget shell;
  1613.     Display *dpy = XtDisplay(shell);
  1614.     Window win = XtWindow(dialog);
  1615.     XEvent event;
  1616.  
  1617.     /* Make sure all our requests get to the server */
  1618.     XFlush(dpy);
  1619.  
  1620.     /* Let motif process all pending exposure events for us. */
  1621.     XmUpdateDisplay(shell);
  1622.  
  1623.     /* Check the event loop for events in the dialog ("Stop"?) */
  1624.     while (XCheckMaskEvent(dpy,
  1625.             ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
  1626.             PointerMotionMask | KeyPressMask | KeyReleaseMask,
  1627.             &event)) {
  1628.         /* got an "interesting" event. */
  1629.         if (event.xany.window == win)
  1630.             XtDispatchEvent(&event); /* it's in our dialog.. */
  1631.         else /* uninteresting event--throw it away and sound bell */
  1632.             XBell(dpy, 50);
  1633.     }
  1634.     return stopped;
  1635. }
  1636.  
  1637.  
  1638. -----------------------------------------------------------------------------
  1639. Subject: 166)  Can I use the hourglass that mwm uses?
  1640.  
  1641. [Last modified: March 93]
  1642.  
  1643. Answer: The hourglass used by mwm is hard-coded into code that is subject to
  1644. OSF copyright. In Motif 1.2 though, the bitmaps for this and other things
  1645. (information, no_enter, question, warning, working) were made available.  The
  1646. install process will probably add them to /usr/include/X11/bitmaps.
  1647. Otherwise, just use the watch cursor XC_watch of the previous question,
  1648. because that has the same semantics.
  1649.  
  1650.  
  1651.  
  1652. -----------------------------------------------------------------------------
  1653. Subject: 167)  What order should the libraries be linked in?
  1654.  
  1655. [Last modified: August 92]
  1656.  
  1657. Answer: At link time, use the library order  -lXm -lXt -lX11. There are two
  1658. reasons for this (dbrooks@osf.org):
  1659.  
  1660. On most systems, the order matters because the linker won't re-scan a library
  1661. once it is done with it.  Thus any references to Xlib calls from Xm will
  1662. probably be unresolved.
  1663.  
  1664. The [other] problem is that there are two VendorShell widgets. A dummy is
  1665. provided in the Xt library, but a widget set will rely on its own being
  1666. referenced.  If you mention Xt first, the linker will choose the wrong one.
  1667.  
  1668. Motif code will wrongly assume the Motif VendorShell has been class-
  1669. initialized [and will probably crash].
  1670.  Xaw has a similar problem, but a softer landing; it only complains about
  1671. unregistered converters.
  1672.  
  1673.  
  1674. -----------------------------------------------------------------------------
  1675. Subject: 168)  How do I use xmkmf for Motif clients?
  1676.  
  1677. [Last modified: October 1992]
  1678.  
  1679. Answer: This advice comes from dbrooks@osf.org:
  1680.  
  1681. There are a number of intractable problems with using X configuration files
  1682. and xmkmf, while trying to make it easy to build Motif.  Not the least of
  1683. these, but one I've never heard mentioned yet, is that the rules for
  1684. contructing the names of shared library macros are machine-dependent, and in
  1685. the various xxxLib.tmpl files.  Do we edit all those files to add definitions
  1686. for XMLIB, DEPXMLIB, etc., or do we put a maze of #ifdefs into the Motif.tmpl
  1687. file?
  1688.  
  1689. Please note that, if you install Motif, it overwrites your installed
  1690. Imake.tmpl with one that includes Motif.tmpl and Motif.rules.
  1691.  
  1692. With those caveats, I think the following guidelines will help.
  1693.  
  1694. David Brooks OSF
  1695.  
  1696. Clients in the X11R5 release use the xmkmf command to build Makefiles.  In
  1697. general, the xmkmf command cannot be used for Motif clients, because of the
  1698. need to consider the UseInstalledMotif flag separately.  Since xmkmf is a
  1699. simple script that calls imake, it is easy to construct the proper call to
  1700. imake using the following rules.
  1701.  
  1702. In the following, replace {MTOP} by the toplevel directory with the Motif
  1703. source tree, and {XTOP} by the toplevel ("mit") directory with the X source.
  1704. It is assumed that the directory containing your installed imake is in your
  1705. PATH.
  1706.  
  1707. When needed, the imake variables XTop and MTop are normally set in your
  1708. site.def (to {XTOP} amd {MTOP} respectively); however they may also be set
  1709. with additional -D arguments to imake.
  1710.  
  1711. 1. With both X and Motif in their source trees, ensure the imake variables
  1712.    XTop and MTop are set, and use:
  1713.  
  1714.         ${XTOP}/config/imake -I{MTOP}/config
  1715.  
  1716. 2. With Motif in its source tree, and X installed, ensure MTop is set, and
  1717.    use:
  1718.  
  1719.         imake -I{MTOP}/config -DUseInstalled
  1720.  
  1721. 3. With both Motif and X installed, and a nonstandard ProjectRoot (see
  1722.    site.def for an explanation of this), use:
  1723.  
  1724.         imake -DUseInstalled -DUseInstalledMotif -I{ProjectRoot}/lib/X11/config
  1725.  
  1726.    or, if the configuration files are in /usr/lib/X11/config:
  1727.  
  1728.         imake -DUseInstalled -DUseInstalledMotif
  1729.  
  1730.  
  1731. To build a simple Imakefile, remember to include lines like this:
  1732.  
  1733.         LOCAL_LIBRARIES = XmClientLibs
  1734.                 DEPLIBS = XmClientDepLibs
  1735.  
  1736. Or, for a client that uses uil/mrm, replace these by MrmClientLibs and
  1737. MrmClientDepLibs, and also use:
  1738.  
  1739.         MSimpleUilTarget(program)
  1740.  
  1741. to build the client and uid file.  Look at the demos for more examples.
  1742.  
  1743.  
  1744. And Paul Howell <grue@engin.umich.edu> added:
  1745.  
  1746. i did this, calling the new script "xmmkmf".  It passes both -DUseInstalled
  1747. and -DUseInstalledMotif.
  1748.  
  1749. and i modified the stock R5 Imake.tmpl to do this:
  1750.  
  1751. #include <Project.tmpl>
  1752. #ifdef UseInstalledMotif
  1753. #include <Motif.tmpl>
  1754. #endif
  1755.  
  1756. #include <Imake.rules>
  1757. #ifdef UseInstalledMotif
  1758. #include <Motif.rules>
  1759. #endif
  1760.  
  1761. the result was something that does both athena and motif rules.  and it really
  1762. works, just that easy!
  1763.  
  1764.  
  1765. -----------------------------------------------------------------------------
  1766. Subject: 169)  How do I make context sensitive help?  The Motif Style Guide
  1767. says that an application must initiate context-sensitive help by changing the
  1768. shape of the pointer to the question pointer. When the user moves the pointer
  1769. to the component help is wanted on and presses BSelect, any available context
  1770. sensitive help for the component must be presented, and the pointer reverts
  1771. from the question pointer.
  1772. [Last modified: August 92]
  1773.  
  1774. Answer: A widget that gives context sensitive help would place this help in
  1775. the XmNhelpCallback function. To trigger this function: (from Martin G C
  1776. Davies, mgcd@se.alcbel.be)
  1777.  
  1778. I use the following callback that is called when the "On Context" help
  1779. pulldown menu is selected. It does the arrow bit and calls the help callbacks
  1780. for the widget. It also zips up the widget tree looking for help if needs be.
  1781. I don't restrict the arrows motion so I can get help on dialog boxes. No
  1782. prizes for guessing what "popup_message" does.
  1783.  
  1784.  
  1785. static void ContextHelp(
  1786.     Widget              w ,
  1787.     Opaque              * tag ,
  1788.     XmAnyCallbackStruct * callback_struct
  1789. )
  1790. {
  1791.     static Cursor   context_cursor = NULL ;
  1792.     Widget          context_widget ;
  1793.  
  1794.     if ( context_cursor == NULL )
  1795.         context_cursor = XCreateFontCursor( display, XC_question_arrow ) ;
  1796.  
  1797.     context_widget = XmTrackingLocate( top_level_widget,
  1798.                                 context_cursor, FALSE ) ;
  1799.  
  1800.     if ( context_widget != NULL ) /* otherwise its not a widget */
  1801.     {
  1802.         XmAnyCallbackStruct cb ;
  1803.  
  1804.         cb.reason = XmCR_HELP ;
  1805.         cb.event = callback_struct->event ;
  1806.  
  1807.         /*
  1808.          * If there's no help at this widget we'll track back
  1809.            up the hierarchy trying to find some.
  1810.          */
  1811.  
  1812.         do
  1813.         {
  1814.             if ( ( XtHasCallbacks( context_widget, XmNhelpCallback ) ==
  1815.                                                 XtCallbackHasSome ) )
  1816.             {
  1817.                 XtCallCallbacks( context_widget, XmNhelpCallback, & cb ) ;
  1818.                 return ;
  1819.             }
  1820.             else
  1821.                 context_widget = XtParent( context_widget ) ;
  1822.         } while ( context_widget != NULL ) ;
  1823.     }
  1824.  
  1825.     popup_message( "No context-sensitive help found\n\
  1826. for the selected object." ) ;
  1827. }
  1828.  
  1829.  
  1830.  
  1831. Dave Bonnett suggested, to use the following translations for XmText (and
  1832. XmTextField) widgets to get the same help with key strokes, and to provide an
  1833. accelerator label in the Context help menu entry.
  1834.  
  1835. MyApp*XmText*translations: #override\n\
  1836.                                 <Key>F1:    Help()
  1837.  
  1838. MyApp*Help_menu*Contextual Help.acceleratorText:   F1
  1839.  
  1840. MyApp*defaultVirtualBindings:           osfBackSpace : <Key>Delete\n\
  1841.                                         osfRight : <Key>Right\n\
  1842.                                         osfLeft  : <Key>Left\n\
  1843.                                         osfUp    : <Key>Up\n\
  1844.                                         osfHelp  : <Key>F1\n\
  1845.                                         osfDown  : <Key>Down
  1846.  
  1847.  
  1848. -----------------------------------------------------------------------------
  1849. Subject: 170)  How do I debug a modal interaction?
  1850.  
  1851. When an application crashes in a modal section (such as in a modal dialog, a
  1852. menu or when a drag and drop is in action), I cannot access the debugger.
  1853.  
  1854. [Last modified: January 1993]
  1855.  
  1856. Answer: Run the debugger on one display while the application writes to
  1857. another display.  ---------
  1858. --------------------------------------------------------------------
  1859. Subject: 171)+ How can I disable Drag and Drop in my Motif 1.2 client ?
  1860.  
  1861. [Last modified: December]
  1862.  
  1863. Answer: Set the XmDisplay drag-protocol resources to XmDRAG_NONE.
  1864.         The following code fragment demonstrates this:
  1865.  
  1866. #include <Xm/Display.h>
  1867.  
  1868.  
  1869.     dw = XmGetXmDisplay(XtDisplay(shell));
  1870.     /* where "shell" is your client's top-level shell. */
  1871.  
  1872.     XtVaSetValues(dw, XmNdragInitiatorProtocolStyle, XmDRAG_NONE, NULL);
  1873.     XtVaSetValues(dw, XmNdragReceiverProtocolStyle,  XmDRAG_NONE, NULL);
  1874.  
  1875.  
  1876. thanks to Lance Purple (purple@austin.ibm.com)
  1877.  
  1878. -----------------------------------------------------------------------------
  1879. Subject: 172)  Where can I get info on the Motif drag and drop protocol?
  1880.  
  1881. [Last modified: March]
  1882.  
  1883. Answer: The drag and drop protocol implemented by OSF is not stable, so they
  1884. have not published it yet. The API should remain stable though.  The OSF
  1885. protocol is not compatable with the OpenLook protocol.  OSF and Sun are
  1886. working on a joint protocol for publication.
  1887.  
  1888. For programming examples on Motif D&D, see the Motif 1.2 Programmers Guide.
  1889.  
  1890. For a third alternative, try Roger Reynolds D&D protocol, available from
  1891. netcom.com in /pub/rogerr.
  1892.  
  1893. -----------------------------------------------------------------------------
  1894. Subject: 173)  TOPIC: ACKNOWLEDGEMENTS
  1895.  
  1896. This list was compiled using questions and answers posed to
  1897. comp.windows.x.motif and motif-talk. Some extracts were also taken from FAQs
  1898. of comp.windows.x.  To all who contributed one way or the other, thanks! I
  1899. haven't often given individual references, but  you may recognise
  1900. contributions. If I have mangled them too much, let me know.
  1901.  
  1902.  
  1903.  
  1904. +----------------------+---+
  1905.   Jan Newmarch, Information Science and Engineering,
  1906.   University of Canberra, PO Box 1, Belconnen, Act 2616
  1907.   Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
  1908.  
  1909.   ACSnet: jan@ise.canberra.edu.au
  1910.   ARPA:   jan%ise.canberra.edu.au@uunet.uu.net
  1911.   UUCP:   {uunet,ukc}!munnari!ise.canberra.edu.au!jan
  1912.   JANET:  jan%au.edu.canberra.ise@EAN-RELAY
  1913.  
  1914.  
  1915. Jan Newmarch of  has been maintaining this FAQ and has really helped a great
  1916. many of us by providing this valuable service.  He deserves a big round of
  1917. applause for his efforts.  I use this resource all the time and it has saved
  1918. me countless hours with manual and source code trying to relearn what others
  1919. have already discovered.  Jan`s efforts are gratefully acknowledged here.
  1920.  
  1921. I am maintaining the FAQ now and will strive to maintain the quality
  1922. that Jan has acheived. Enjoy!
  1923. Brian
  1924.  
  1925. Brian Dealy - X Professional Organization
  1926. dealy@kong.gsfc.nasa.gov
  1927.  
  1928.  
  1929. (301) 572-8267
  1930. (410) 799-7197 (FAX)
  1931. +--------------------------+
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599. -- 
  2600. ..........................
  2601.  
  2602.  
  2603.